package com.xiegang.apipassenger.Service;

import com.xiegang.apipassenger.remote.ServicePriceClient;
import com.xiegang.internalcommon.dto.ForecastPriceDto;
import com.xiegang.internalcommon.dto.ResponseResult;
import com.xiegang.internalcommon.response.ForecastpriceResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author xieGang
 * @description
 * @date 2023/3/9 20:10
 **/

@Slf4j
@Service
public class ForecastPriceService {

    @Autowired
    private ServicePriceClient servicePriceClient;

    public ResponseResult forecastPrice(String depLongitude,String deplatitude,String destLongitude,String destLatiude,String cityCode,String vehicleType){

        log.info("出发地经度："+depLongitude);
        log.info("出发地纬度："+deplatitude);
        log.info("目的地经度："+destLongitude);
        log.info("目的地纬度："+destLatiude);

        ForecastPriceDto forecastPriceDto = new ForecastPriceDto();
        forecastPriceDto.setDestLatiude(destLatiude);
        forecastPriceDto.setDestLongitude(destLongitude);
        forecastPriceDto.setDeplatitude(deplatitude);
        forecastPriceDto.setDepLongitude(depLongitude);
        forecastPriceDto.setCityCode(cityCode);
        forecastPriceDto.setVehicleType(vehicleType);


        ResponseResult<ForecastpriceResponse> forecast = servicePriceClient.forecastPrice(forecastPriceDto);

        Double price = forecast.getData().getPrice();

        ForecastpriceResponse forecastpriceResponse = new ForecastpriceResponse();
        forecastpriceResponse.setPrice(price);
        forecastpriceResponse.setCityCode(cityCode);
        forecastpriceResponse.setVehicleType(vehicleType);

        return ResponseResult.success(price);
    }
}
